<template >
<view class="container">
  <view class="coupon-form">
    <view class="input-box">
      <input class="coupon-sn" name="rele" placeholder="请输入业务主管确认码" v-model="reletion_dode"  />
      
    </view>
    <button class="add-btn" @click="addReletion" type="primary" plain="true">绑定账号</button>
  </view>
  <view class="help">说明</view>
  <view class="notices">新加入的人员微信必须在这里输入主管发送给你的内部账号确认码，否则你所有的业务订单将不会得到业务主管的审核！</view>
  
</view>
</template>

<script>
import api from "@/utils/api";
import wx from "wx";
import wxParse from "mpvue-wxparse";

import getCurrentPages from "wxFunction";
import user from "@/services/user";
var app = getApp();
export default {
  data() {
    return {
      reletion_dode: ""
    };
  },

  onShow() {
    let userInfo = wx.getStorageSync("userInfo");
    // console.log("userInfo" + userInfo);
    // this.reletion_dode = userInfo.id;
  },

  methods: {
    async addReletion() {
      console.log("reletion_dode：" + this.reletion_dode);
      // // 验证订单内容是否填写
      if (!this.reletion_dode) {
        wx.showToast({
          image: "/static/images/icon_error.png",
          title: "请填写内容",
          mask: true
        });
        return false;
      }
      const res = await api.reletionSubmit({
        reletion_dode: this.reletion_dode
      });
      console.log(res);
      console.log("添加，请求结果", res.errmsg);
      if (res.errno === 0) {
        wx.showToast({
          title: "添加成功",
          mask: true
        });
      console.log("res.data.userInfo请求结果", res.data.userInfo);
      let userRele =  res.data.userInfo;
      let userInfo = wx.getStorageSync("userInfo");

        app.globalData.userInfo = userRele;
        wx.setStorageSync("userInfo",userRele);
        wx.switchTab({
                      url: "/pages/index/index",
                      success: function(e) {
                        // console.log('getCurrentPages的页面栈', getCurrentPages());
                        var page = getCurrentPages().pop();
                        // console.log('当前page', page);
                        if (page === undefined || page === null) return;
                        page.onShow();
                      }
                    });

        // this.openAttr = !this.openAttr;
        //this.cartGoodsCount = res.data.cartTotal.goodsCount;
      } else {
        wx.showToast({
          image: "/static/images/icon_error.png",
          title: "" + res.errmsg,
          mask: true
        });
      }
    },
    // 原生的分享功能
    onShareAppMessage: function() {
      return {
        title: "cs28Shop",
        desc: "昌顺28小程序粮油商城",
        path: "/pages/ucenter/reletion"
      };
    }
  }
};
</script>

<style>
page {
  background: #f4f4f4;
  min-height: 100%;
}

.container {
  background: #f4f4f4;
  min-height: 100%;
  padding-top: 30rpx;
}

.coupon-form {
  height: 110rpx;
  width: 94%;
  background: #fff;
  padding-left: 30rpx;
  padding-right: 30rpx;
  padding-top: 20rpx;
  display: flex;
}

.input-box {
  flex: 1;
  height: 70rpx;
  color: #333;
  font-size: 24rpx;
  background: #fff;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4rpx;
  margin-right: 30rpx;
}

.input-box .coupon-sn {
  position: absolute;
  top: 10rpx;
  left: 30rpx;
  height: 50rpx;
  width: 100%;
  color: #000;
  line-height: 50rpx;
  font-size: 24rpx;
}

.clear-icon {
  position: absolute;
  top: 21rpx;
  right: 30rpx;
  width: 28rpx;
  height: 28rpx;
}

.add-btn {
  height: 70rpx;
  border: none;
  width: 188rpx;
  background: #b4282d;
  border-radius: 0;
  line-height: 70rpx;
  color: #fff;
  font-size: 28rpx;
}

.add-btn.disabled {
  background: #ccc;
}

.help {
  height: 72rpx;
  line-height: 72rpx;
  text-align: right;
  padding-right: 30rpx;
  background: url(https://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/couponHelp-4768607555.png)
    590rpx center no-repeat;
  background-size: 28rpx;
  color: #999;
  font-size: 24rpx;
}

.notices {
  height: 72rpx;
  line-height: 72rpx;
  text-align: right;
  padding-right: 30rpx;

  background-size: 28rpx;
  color: rgb(214, 26, 26);
  font-size: 32rpx;
}

.coupon-list {
  width: 100%;
  height: auto;
  overflow: hidden;
  padding-left: 30rpx;
  padding-right: 30rpx;
}

.item {
  position: relative;
  height: 290rpx;
  width: 100%;
  background: linear-gradient(to right, #cfa568, #e3bf79);
  margin-bottom: 30rpx;
  padding-top: 52rpx;
}

.tag {
  height: 32rpx;
  background: #a48143;
  padding-left: 16rpx;
  padding-right: 16rpx;
  position: absolute;
  left: 20rpx;
  color: #fff;
  top: 20rpx;
  font-size: 20rpx;
  text-align: center;
  line-height: 32rpx;
}

.content {
  margin-top: 24rpx;
  margin-left: 40rpx;
  display: flex;
  margin-right: 40rpx;
  flex-direction: row;
  align-items: center;
}

.content .left {
  flex: 1;
}

.name {
  font-size: 44rpx;
  color: #fff;
  margin-bottom: 14rpx;
}

.time {
  font-size: 24rpx;
  color: rgba(255, 255, 255, 0.8);
  line-height: 30rpx;
}

.content .right {
  width: 162rpx;
}

.go {
  height: 48rpx;
  border: none;
  width: 162rpx;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 4rpx;
  line-height: 48rpx;
  color: #b69150;
  font-size: 24rpx;
}

.condition {
  position: absolute;
  width: 90%;
  bottom: 0;
  left: 0;
  height: 78rpx;
  background: rgba(0, 0, 0, 0.08);
  padding: 24rpx 40rpx;
  display: flex;
  flex-direction: row;
}

.condition .txt {
  display: block;
  height: 30rpx;
  flex: 1;
  overflow: hidden;
  font-size: 24rpx;
  line-height: 30rpx;
  color: #fff;
}

.condition .icon {
  margin-left: 30rpx;
  width: 24rpx;
  height: 24rpx;
}
</style>
